<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace plugins\system_info;

use cmf\lib\Plugin;
use think\Db;

class SystemInfoPlugin extends Plugin
{

    public $info = [
        'name'        => 'SystemInfo',
        'title'       => '系统信息',
        'description' => '系统信息',
        'status'      => 1,
        'author'      => 'ThinkCMF',
        'version'     => '1.0'
    ];

    public $hasAdmin = 0;//插件是否有后台管理界面


    // 插件安装
    public function install()
    {
        return true;//安装成功返回true，失败false
    }

    // 插件卸载
    public function uninstall()
    {
        return true;//卸载成功返回true，失败false
    }

    public function adminDashboard()
    {

        $mysql = Db::query("select VERSION() as version");
        $mysql = $mysql[0]['version'];
        $mysql = empty($mysql) ? lang('UNKNOWN') : $mysql;

        $version = THINKCMF_VERSION;

        $site_info = cmf_get_option('site_info');
        //server infomation
        $info = array(
            lang('SITE_NAME')             => '政务微信',
            lang('CURRENT_VERSION')       => 'V3.0',
            lang('PROGRAM_DEVELOPMENT')   => '优思尔',
            lang('OPERATING_SYSTEM')      => PHP_OS,
            lang('OPERATING_ENVIRONMENT') => $_SERVER["SERVER_SOFTWARE"],
            lang('PHP_VERSION')           => PHP_VERSION,
            lang('PHP_RUN_MODE')          => php_sapi_name(),
            lang('MYSQL_VERSION')         => $mysql,
            // 'ThinkPHP版本'                => THINK_VERSION,
            // lang('SERVER_NAME')           => $_SERVER['SERVER_NAME'],
            // lang('SERVER_PORT')           => $_SERVER['SERVER_PORT'],
            // lang('DOCUMENT_ROOT')         => $_SERVER["DOCUMENT_ROOT"],
            lang('HTTP_USER_AGENT')       => substr($_SERVER['HTTP_USER_AGENT'], 0, 40),
            lang('SERVER_PROTOCOL')       => $_SERVER['SERVER_PROTOCOL'],
            lang('REQUEST_METHOD')        => $_SERVER['REQUEST_METHOD'],
            lang('UPLOAD_MAX_FILESIZE')   => ini_get('upload_max_filesize'),
            lang('MAX_EXECUTION_TIME')    => ini_get('max_execution_time') . "s",
            lang('SERVER_TIME')           => date("Y年n月j日 H:i:s"),
            lang('BEIJING_TIME')          => gmdate("Y年n月j日 H:i:s",time()+8*3600),
            // lang('SERVER_ADDR')           => $_SERVER['SERVER_NAME'].' [ '.gethostbyname($_SERVER['SERVER_NAME']).' ]',
            // lang('REMOTE_ADDR')           => $_SERVER['REMOTE_ADDR'],
            // lang('DISK_FREE_SPACE')       => round((@disk_free_space(".") / (1024 * 1024)), 2) . 'M',
            lang('COPYRIGHT_DECLARATION')       => '1、本软件为商业软件；<br> 2、您可以对本系统进行修改和美化，但必须保留完整的版权信息，不得将修改后的版本用于任何商业目的；<br> 3、本软件受中华人民共和国《著作权法》《计算机软件保护条例》等相关法律、法规保护，作者保留一切权利。<br> 4、如有可能，请在您的网站上添加本站链接。',
        );


        $this->assign('server_info', $info);

        return [
            'width'  => '12 layui-col-sm12',
            'view'   => $this->fetch('widget'),
            'plugin' => 'SystemInfo'
        ];
    }

}
